<!--
@description ：批量加好友--拓客进度
-->

<template>
  <div class="app-container">
    <NormalForm :enumOpt="enumOpt" :formList="formList" :operateForm="queryForm" pageTitle="拓客进度"
                @handleQuery="handleQuery" @handleReset="handleReset"></NormalForm>
    <div class="g-card">
      <div class="right-btn" style="margin-right: 0; padding: 0 0 16px 0">
        <el-button plain size="mini" type="primary" @click="exportDetail" v-has-permi="['admin:beath:auto:export']">一键导出
        </el-button>
      </div>
      <el-table v-loading="loading" :data="tableList" max-height="560" min-height="420" style="width: 100%">
        <el-table-column :show-overflow-tooltip="false" align="center" label="电话号码" min-width="160"
                         prop="mobile"></el-table-column>
        <el-table-column :show-overflow-tooltip="false" align="center" label="昵称" min-width="160"
                         prop="wechatNickname"></el-table-column>
        <el-table-column :show-overflow-tooltip="false" align="center" label="备注名" min-width="160"
                         prop="cusName">
          <template slot-scope="{ row }">
            {{ row.cusName || '--' }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="false" align="center" label="状态" min-width="120"
                         prop="addStateValue"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" align="center" label="失败原因" min-width="200"
                         prop="failed"></el-table-column>
        <el-table-column :show-overflow-tooltip="false" align="center" label="添加时间" min-width="170"
                         prop="addTime"></el-table-column>
        <el-table-column :show-overflow-tooltip="false" align="center" label="更新时间" min-width="170"
                         prop="updateTime"></el-table-column>
      </el-table>
      <NormalPagination :currentPage="queryForm.pageNum" :pageSize="queryForm.pageSize" :total="total"
                        @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange"></NormalPagination>
    </div>
  </div>
</template>
<script>

import {getAddScheduleList} from "@/api/beathAddAuto";
import moment from "moment";
import {downLoadFile} from "@/utils/common";

export default {
  name: "beathAutoSchedule", //批量加好友--拓客进度
  props: {},
  components: {},
  data() {
    return {
      queryForm: {
        addState: '',
        name: '',
        pageNum: 1,
        pageSize: 20,
      },
      formList: [
        {
          label: '电话号码/昵称/备注名',
          value: '',
          prop: 'name',
          type: 'INPUT',
          emunName: '',
        },
        {
          label: '任务状态',
          value: '',
          prop: 'addState',
          type: 'SELECT',
          emunName: 'addStateList',
        }
      ],
      enumOpt: {
        addStateList: [
          {dictValue: '0', dictLabel: '成功'},
          {dictValue: '1', dictLabel: '失败'},
        ],
      },
      loading: false,
      tableList: [
        {},
        {},
      ],
      total: 0,
    }
  },
  watch: {},
  methods: {
    handleQuery() {
      this.queryForm.pageNum = 1
      this.getListFn()
    },
    handleReset() {
      this.queryForm = {
        addState: '',
        name: '',
        pageNum: 1,
        pageSize: 20,
      }
      this.getListFn()
    },
    getListFn() {
      let obj = {
        ...this.queryForm,
        batchId: this.$route.query.batchId
      }
      this.loading = true
      getAddScheduleList(obj).then(res => {
        this.tableList = res.rows || []
        this.total = res?.total || 0
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    // 翻页
    handleSizeChange(value) {
      this.queryForm.pageNum = 1
      this.queryForm.pageSize = value
      this.getListFn()
    },
    handleCurrentChange(value) {
      this.queryForm.pageNum = value
      this.getListFn()
    },
    exportDetail() {
      const params = {
        ...this.queryForm,
        batchId: this.$route.query.batchId
      }
      downLoadFile('/admin/add/schedule/export', params, '拓客进度.xlsx', ()=> {}, 'post')
    }
  },
  mounted() {
     this.handleQuery()
  },
  created() {
  },
}

</script>

<style lang="scss" scoped>
@import '@/styles/base.scss';

.app-container {
  height: 100%;
  padding: 0;
}

.g-card {
  padding: 20px;
}

</style>
